﻿using SMTPAPI.InterfaceImplementation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net.Mail;

namespace SMTPAPIUnitTest
{
    
    
    /// <summary>
    ///This is a test class for SenderInfoTest and is intended
    ///to contain all SenderInfoTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SenderInfoTest
    {

        /// <summary>
        ///A test for CreateMailBasicFormat - for success senario with html enable body.
        ///</summary>
        [TestMethod()]
        public void CreateMailBasicFormatTest_ForSuccessSenarioWithHTMLEnableBody()
        {
            SenderInfo target = new SenderInfo(); 
            string senderAddress = "erandika1986@gmail.com"; 
            string subject = "Unit test subject"; 
            string body = "Test mail body";
            bool isHtmlBody = true;
            string mailHeaderPath = @"Koala.jpg";

            MailMessage actual= target.CreateMailBasicFormat(senderAddress, subject, body, isHtmlBody, mailHeaderPath);

            string expectedSenderAddress= "erandika1986@gmail.com";
            string expectedSubject = "Unit test subject";
            string expectedBody = "<html><head><title>Unit test subject</title></head><body><img src=Koala.jpg/><p>Test mail body</p></body></html>";

            Assert.AreEqual(expectedSenderAddress, actual.From.ToString());
            Assert.AreEqual(expectedSubject, actual.Subject);
            Assert.AreEqual(expectedBody, actual.Body);
            Assert.AreEqual(true, actual.IsBodyHtml);
        }

        /// <summary>
        ///A test for CreateMailBasicFormat - for success senario without html enable body.
        ///</summary>
        [TestMethod()]
        public void CreateMailBasicFormatTest_ForSuccessSenarioWithOutHTMLEnableBody()
        {
            SenderInfo target = new SenderInfo();
            string senderAddress = "erandika1986@gmail.com";
            string subject = "Unit test subject";
            string body = "Test mail body";
            bool isHtmlBody = false;

            MailMessage actual = target.CreateMailBasicFormat(senderAddress, subject, body, isHtmlBody, null);

            string expectedSenderAddress = "erandika1986@gmail.com";
            string expectedSubject = "Unit test subject";
            string expectedBody = "Test mail body"; 

            Assert.AreEqual(expectedSenderAddress, actual.From.ToString());
            Assert.AreEqual(expectedSubject, actual.Subject);
            Assert.AreEqual(expectedBody, actual.Body);
            Assert.AreEqual(false, actual.IsBodyHtml);
        }
    }
}
